import sys
from time import time
sys.path.insert(0,'../..')
from rmpoly import *
from rmpoly.free_algebra import FreeAlgebra
from gmpy import mpz,mpq

try:
  h = int(sys.argv[1])
except:
  print 'prog h'
  sys.exit()

def bench_bch(h):
  fa = FreeAlgebra('A,B',mpq)
  A,B = fa.gens()
  rp,x,y = ncrgens('x,y',10,fa,order='grlex')
  t0 = time() 
  pa = (x*A).exp('_t',h)
  pb = (y*B).exp('_t',h)
  p = pa.mul_trunc(pb,'_t',h)
  p1 = p.log('_t',h)
  t1 = time() 
  #print p1
  print '%s t=%.2f' %(sys.argv, t1-t0)

bench_bch(h)

